<!doctype html>
<html>
 <head>
  <meta charset="UTF-8">
  <meta name="Author" content="hello">
  <title>随机色块</title>
  <style type="text/css">
	*{margin:0;padding:0;}
	ul,ol{list-style:none;}
	a{text-decoration:none;}

	span{
		display:inlineblock;
		width:80px;
		height:40px;
		float:left;
		color:white;
		text-align:center;
		background:red;
		line-height:40px;
	}
  </style>
  <script type="text/javascript">
		
		var count = 0,
			timer = setInterval(function(){
				var oSpan = document.createElement('span');
				var s = "#";
				for(var i=0;i<6;i++){
					s += Math.floor(Math.random() * 16).toString(16);
				}
				
				oSpan.style.background = s;
				oSpan.innerHTML = s;
				document.body.appendChild(oSpan);
				count++;
				console.log(count);
				if(count == 500){
					clearInterval(timer);
				}
		},1);
  </script>
 </head>
 <body>

 </body>
</html>
